package com.xiaoq.push.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.xiaoq.apis.user.IPushMessageApi;
import com.xiaoq.push.vo.MessageSenderVo;

@Service(interfaceClass=IPushMessageApi.class,version="1.0.0")
public class PushMessageApiDubboService implements IPushMessageApi {
	
	@Autowired
	private PushMessageService pushMessage;
	
	@Autowired
	JdPushService jdPushService;

	@Override
	public boolean sendMessage(String userId, String catalogueCode, String msgTitle, String msgContent,String mesTarId,String mesType,String cornershopId) {
		
		
		return pushMessage.sendMessageToXiaomi( userId,  catalogueCode,  msgTitle,  msgContent, mesTarId, mesType, cornershopId,null,false);
	}

	@Override
	public boolean sendMessageToIOSUsers(List<String> regIds, String catalogueCode, String msgTitle, String msgContent,
			String mesTarId, String mesType, String cornershopId,String mesUrl,boolean mutable_content) {
		MessageSenderVo messageSenderVo = new MessageSenderVo();
		messageSenderVo.setCornershopId(cornershopId);
		messageSenderVo.setMesTarId(mesTarId);
		messageSenderVo.setMesType(mesType);
		messageSenderVo.setMsgCatalogueCode(catalogueCode);
		messageSenderVo.setMsgContent(msgContent);
		messageSenderVo.setMsgTitle(msgTitle);
		messageSenderVo.setMesUrl(mesUrl);
		jdPushService.sendMessageToMultiIOSUsers(messageSenderVo, regIds,mutable_content);
		return true;
	}

	@Override
	public boolean sendMessageToAndroidUsers(List<String> regIds, String catalogueCode, String msgTitle,
			String msgContent, String mesTarId, String mesType, String cornershopId) {
		MessageSenderVo messageSenderVo = new MessageSenderVo();
		messageSenderVo.setCornershopId(cornershopId);
		messageSenderVo.setMesTarId(mesTarId);
		messageSenderVo.setMesType(mesType);
		messageSenderVo.setMsgCatalogueCode(catalogueCode);
		messageSenderVo.setMsgContent(msgContent);
		messageSenderVo.setMsgTitle(msgTitle);
		jdPushService.sendMessageToMultiAndroidUsers(messageSenderVo, regIds);
		return true;
	}

	@Override
	public boolean sendMessageWithImag(String userId, String catalogueCode, String msgTitle, String msgContent,
			String mesTarId, String mesType, String cornershopId, String mesUrl, boolean mutable_content) {
		return pushMessage.sendMessageToXiaomi( userId,  catalogueCode,  msgTitle,  msgContent, mesTarId, mesType, cornershopId,mesUrl,mutable_content);
	}

}
